package com.handsome.工厂模式.简单工厂模式.简单工厂模式写法2.order;




import com.handsome.工厂模式.简单工厂模式.简单工厂模式写法2.pizza.Pizza;
import com.handsome.工厂模式.简单工厂模式.简单工厂模式写法2.factory.PizzaFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author niechun
 * @date 2023/1/9 19:32
 */
public class Order {

    public void order(){
        String orderType=null;
        do {
            orderType = getType();
            Pizza pizza = PizzaFactory.createPizza(orderType);
            if (pizza!=null){
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            }else {
                System.out.println("订购失败");
                break;
            }
        } while (true);
    }

    public String getType() {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String name;
        try {
            name = bufferedReader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return name;
    }
}
